package cn.edu.nit.sys.entity;

import cn.edu.nit.sys.enums.ForumStatusEnum;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * @Author 罗文斌
 * @Date 2023/4/11
 * @Version 1.0.0
 */
@Data
@TableName("sys_forum")
public class Forum {

    @TableId(type = IdType.ASSIGN_ID)
    private String id;
    private String userId;
    private String content;
    private boolean anonymous;
    private String images;
    private String status;
    private String createTime;
    @TableField(exist = false)
    private String author;
    @TableField(exist = false)
    private String clazz;
    @TableField(exist = false)
    private ForumStatusEnum statusLabel;
    @TableField(exist = false)
    private List<Map<String, Object>> commentList;
    @TableField(exist = false)
    private String avatar;
    @TableField(exist = false)
    private int likes;
    @TableField(exist = false)
    private int views;
    @TableField(exist = false)
    private int comments;
    @TableField(exist = false)
    private boolean liked;

    public ForumStatusEnum getStatusLabel() {
        if("0".equals(this.status)) {
            return ForumStatusEnum.ONE;
        }else if("1".equals(this.status)) {
            return ForumStatusEnum.TWO;
        }
        return ForumStatusEnum.THREE;
    }
}
